﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace CGShaderIntegration
{
    class HesseSebastianSun
    {
        private Model sun;   
        private TextureCube sunTexture;
        private Effect sunEffect;
        
       

        public HesseSebastianSun(ContentManager Content)
        {
            sun = Content.Load<Model>("models\\hesseSebastianSonne");
            sunTexture = Content.Load<TextureCube>("textures\\HesseSebastianSunCubeMap");
            sunEffect = Content.Load<Effect>("effects\\HesseSebastianSunEffect");            
        }

        public void Draw(Matrix world, Matrix view, Matrix projection)
        {
            foreach (EffectPass pass in sunEffect.CurrentTechnique.Passes)
            {
                // Draw all of the components of the mesh, but we know the cube really
                // only has one mesh
                foreach (ModelMesh mesh in sun.Meshes)
                {
                    // Assign the appropriate values to each of the parameters
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        part.Effect = sunEffect;
                        part.Effect.Parameters["World"].SetValue(world);
                        part.Effect.Parameters["View"].SetValue(view);
                        part.Effect.Parameters["Projection"].SetValue(projection);
                        part.Effect.Parameters["sunNormal"].SetValue(sunTexture);                       
                    }                    
                    mesh.Draw();
                }
            }
        }
    }
}
